Help static analysis with an assertion
authorMatthias Clasen <mclasen@redhat.com>
Tue, 26 May 2020 00:38:16 +0000 (20:38 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 26 May 2020 00:56:09 +0000 (20:56 -0400)
It is hard for clang to see that layouts will
always be smaller than num_layouts, so just assert
that.

gdk/wayland/gdkkeys-wayland.c

index 802463298e5a547cecd2fcd42486a59df8445013..ef41b287ef0c5cd2a569b70d3a4c32622d93407a 100644 (file)
@@ -412,6 +412,7 @@ update_direction (GdkWaylandKeymap *keymap)
        gint layouts, layout;
 
        layouts = xkb_keymap_num_layouts_for_key (keymap->xkb_keymap, key);
+       g_assert (layouts <= num_layouts);
        for (layout = 0; layout < layouts; layout++)
          {
            const xkb_keysym_t *syms;